package scala.patternMatching

object MatchingOnCaseClass {
   
   /*
      Case classes can be pattern matched
		Case classes automatically define hashcode and equals
		Case classes automatically define getter methods for the constructor arguments.
    */
   
   def main(args: Array[String]): Unit = {
      
      case class Persion(name : String, age:Int)
      val Alice = new Persion("Alice",18)
      val Bob = new Persion("Bob",20)
      val John = new Persion("John",22)
      val anonymous = new Persion("Annn",3434)
      
      for(p <- List(Alice,Bob,John,anonymous)){
         p  match {
           case Persion("Alice",_) => println("Hello : Alice")
           case Persion("Bob",_) => println("Hello : Bob")
           case Persion("John", _) => println("Hello : John")
           case _ => println("Another Persion : "+p.name)
         }
      }
   }
}